< previous page page_28 next page >

Page 28
e10a6a0a59f035e870d90cca05b85fce.gif
Private Sub Form_Resize()
    ArrangeControls
End Sub

' Arrange the scroll bars.
Private Sub ArrangeControls()
Dim border_width As Single
Dim got_wid As Single
Dim got_hgt As Single
Dim need_wid As Single
Dim need_hgt As Single
Dim need_hbar As Boolean
Dim need_vbar As Boolean
    ' See how much room we have and need.
    border_width = picOuter.Width - picOuter.ScaleWidth
    got_wid = ScaleWidth - border_width
    got_hgt = ScaleHeight - border_width
    need_wid = picInner.Width
    need_hgt = picInner.Height

    ' See if we need the horizontal scroll bar.
    If need_wid > got_wid Then
        need_hbar = True
        got_hgt = got_hgt - hbarMarble.Height
    End If

    ' See if we need the vertical scroll bar.
    If need_hgt > got_hgt Then
        need_vbar = True
        got_wid = got_wid - vbarMarble.Width

        ' See if we now need the horizontal scroll bar.
        If (Not need_hbar) And need_wid > got_wid Then
            need_hbar = True
            got_hgt = got_hgt - hbarMarble.Height
        End If
    End If

    ' Arrange the controls. 
    picOuter.Move 0, 0, got_wid + border_width, got_hgt + border_width
    If need_hbar Then
        hbarMarble.Move 0, got_hgt + border_width, _
            got_wid + border_width
        hbarMarble.Min = 0
        hbarMarble.Max = picInner.ScaleWidth - got_wid
        hbarMarble.SmallChange = got_wid / 5
        hbarMarble.LargeChange = got_wid
        hbarMarble.Visible = True
    Else
        hbarMarble.Value = 0 
        hbarMarble.Visible = False

 
< previous page page_28 next page >